package controllers

import (
	"gin-AssetManagement/models"
	"github.com/gin-gonic/gin"
	"net/http"
)

// @BasePath /

// Home 控制台页面
// @Summary 控制台页面
// @Schemes http
// @Tags 控制台页面
// @Description 控制台页面
// @Accept json
// @Produce json
// @Success 200 {json} {"code":0,"msg":"成功"}
// @Router /home/index [get]
func Home(g *gin.Context) {
	userID, _ := g.Get("userID")
	username, _ := g.Get("username")
	menus, _ := models.GetMenusByUserId(userID)
	var menusJson models.MenusJson
	menusJsons := models.LoadMenu(&menusJson, menus)
	g.HTML(http.StatusOK, "home/index.html", gin.H{
		"menus":    menusJsons,
		"username": username,
	})
}

func Desktop(g *gin.Context) {
	g.HTML(http.StatusOK, "home/desktop.html", nil)
}
